//
//  MBProgressHUD+Show.m
//  tryshopping.boss
//
//  Created by Mr.Lee on 16/11/8.
//  Copyright © 2016年 Reabam. All rights reserved.
//

#import "MBProgressHUD+Show.h"
static MBProgressHUD *_textHUD;
static MBProgressHUD *HUD;
@implementation MBProgressHUD (Show)
#pragma mark -- 只显示文字
+ (void)showTextHud:(NSString*)message view:(UIView *)view{
    _textHUD = [MBProgressHUD showHUDAddedTo:
                view animated:YES];
    [_textHUD setMode:MBProgressHUDModeText];
    [_textHUD setLabelText:message];
    [_textHUD setMargin:10.f];
//    [_textHUD setYOffset:ScreenHeight/2- ScreenWidth/2];
//    [_textHUD setXOffset:ScreenWidth/2-ScreenWidth/2];
    [_textHUD setRemoveFromSuperViewOnHide:YES];
    [_textHUD setUserInteractionEnabled:NO];
    [_textHUD hide:YES afterDelay:3];
}
#pragma mark -- 只显示文字
+ (void)showTextHudSub:(NSString*)message view:(UIView *)view{
    _textHUD = [MBProgressHUD showHUDAddedTo:
                view animated:YES];
    [_textHUD setMode:MBProgressHUDModeText];
    [_textHUD setLabelText:message];
    [_textHUD setMargin:10.f];
    [_textHUD setYOffset:ScreenHeight/2- ScreenWidth/2-40];
    // [_textHUD setXOffset:240];
    [_textHUD setRemoveFromSuperViewOnHide:YES];
    [_textHUD setUserInteractionEnabled:NO];
    [_textHUD hide:YES afterDelay:3];
    
}

#pragma mark -- 显示圈圈和文字
+ (void)showIndeterminateHud:(NSString*)text delay:(int)delay view:(UIView *)view{
    HUD = [MBProgressHUD showHUDAddedTo:
           view animated:YES];
    
    [HUD setMode:MBProgressHUDModeIndeterminate];
    [HUD setRemoveFromSuperViewOnHide:YES];
//    [HUD setXOffset: ScreenWidth/2-ScreenWidth/2];
    [HUD hide:YES afterDelay:delay];
    [HUD setLabelText:text];
    [HUD setMargin:10.f];
    // NSLog(@"show hud:%@",HUD);
}
#pragma mark -- 显示圈圈和文字
+ (void)showIndeterminateHudSub:(NSString*)text delay:(int)delay view:(UIView *)view
{
    HUD = [MBProgressHUD showHUDAddedTo:
           view animated:YES];
    [HUD setMode:MBProgressHUDModeIndeterminate];
    [HUD setRemoveFromSuperViewOnHide:YES];
    [HUD setXOffset:ScreenWidth/2-ScreenWidth/2];
    [HUD hide:YES afterDelay:delay];
    [HUD setLabelText:text];
    [HUD setMargin:10.f];
}

#pragma mark -- 隐藏
+ (void)hideProgressHUDInternal:(UIView *)view{
    
    MBProgressHUD *hud = [MBProgressHUD HUDForView:view];
    if (hud != nil) {
        
        [hud removeFromSuperview];
    }
}

@end
